/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2009, 2010.

	This file is part of Maxsi Engine.

	Maxsi Engine is free software: you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi engine is distributed in the hope that it will be useful, but WITHOUT
	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
	for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Engine. If not, see <http://www.gnu.org/licenses/>.

	MaxsiEngine.dll
	A general purpose C++ library for the Maxsi Technology Project.

	MaxsiRegression.h
	Regressions using the least squares method. Mathematically proven! And
	Patent-Free! And Abestos-Free! And Software-Free!

******************************************************************************/

#ifndef MaxsiRegression_H
#define MaxsiRegression_H

BeginMaxsiNamespace

//=============================================================================
//	Regression functions using the least squares method!
//=============================================================================

//=============================================================================
//	bool LinearRegression(size_t N, double* X, double* Y, double* A, double* 
//	B);
//
//	Performs a linear regression (Y=A*X+B) on N points and returns true. The
//	double that A points to and the double that B points to is set to the
//	constants that fits best for the dataset. The algorithm uses the least
//	squares method to determine the best fit. X must point to the first of N
//	X values and Y must point to the first of N Y values in the set. 
//=============================================================================
LINK bool LinearRegression(size_t N, double* X, double* Y, double* A, double* B);

//=============================================================================
//	bool ProportionalRegression(size_t N, double* X, double* Y, double* A);
//
//	Performs a regression on the function Y=A*X and finds the best A that
//	satisfies this equation using the least squares method. X must point to the
//	first of N X values and Y must point to the first of N Y values in the	set.
//=============================================================================
LINK bool ProportionalRegression(size_t N, double* X, double* Y, double* A);

//=============================================================================
//	double Correlation(size_t N, double* X, double* Y);
//
//	Calculates the correlation for a fit using the least squares method to fit
//	a Y=A*X+B function on N datapoints given in X and Y.
//=============================================================================
LINK double Correlation(size_t N, double* X, double* Y);

EndMaxsiNamespace

#endif
